#ifndef CONNECT_H
#define CONNECT_H

#include <QObject>

class Connection : public QObject
{
	Q_OBJECT

public:
	Connection(QObject *parent,QTcpSocket * socket);
	Connection(QObject *parent);

	~Connection();
	void Abort();
	bool SendMsg(const seven::TransferMessage& msg);
	bool SendMsg(const seven::MessageType& msgType);
	void SetSocket(QTcpSocket* socket);
	void Disconnect();

signals:
	void revMsg(const seven::TransferMessage& msg);

private slots:
	void readMessage();
	void displayError(QAbstractSocket::SocketError socketError);
	

protected:
	QTcpSocket* GetSocket() {return tcpSocket;}

private:
	QTcpSocket *tcpSocket;
	qint64 messageSize;
};

#endif // CONNECT_H
